PHP how to skip file upload if file already exist

76

if(isset($_FILES["user_image"]) && (int)$_FILES["user_image"]['error']===0)
{
    $extension = explode('.', $_FILES['user_image']['name']);
    $new_name = rand() . '.' . $extension[1];
    $destination = '../upload/' . $new_name;
    move_uploaded_file($_FILES['user_image']['tmp_name'], $destination);
    return $new_name;
}

Comments

Submit
0 Comments